<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('student/index')}">所有学生</a></li>
		<li><a href="{:url('student/add')}">添加学生</a></li>
        <li  class="active"><a href="{:url('student/edit')}">编辑学生</a></li>
    </ul>
    <form class="form-horizontal js-ajax-form margin-top-20" action="{:url('student/editPost')}" method="post">
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">学生名称:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-name" name="name" value="{$student.name}">
				<input type="hidden" name="id" value="{$student.id}">
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">头像:</label>
                <div class="col-md-6 col-sm-10">
                    <input id="photo-1" type="hidden" name="image" value="{$student.image}">
                    <input id="photo-1-name" type="text" name="photo_name" title="图片名称" value="{$student.image}">
                    <img src="__ROOT__/upload/{$student.image}" width="50px" height="50px" id="photo-1-preview">
                    <a href="javascript:uploadOneImage('图片上传','#photo-1');" id="picture">重新上传</a>
                </div>
        </div>
        <div class="form-group">
            <label for="input-student_login" class="col-sm-2 control-label"><span class="form-required">*</span>所属学校</label>
            <div class="col-md-6 col-sm-10">
                <select id="selectSchool" name="school_id">
                    <option value="">--请选择学校--</option>
                    <foreach name="school" item="vo">
                        <if $school_id == $vo.id>
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                        <else />
                            <option value="{$vo.id}">{$vo.name}</option>
                        </if>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-student_login" class="col-sm-2 control-label"><span class="form-required">*</span>所属班级</label>
            <div class="col-md-6 col-sm-10">
                <select name="cid" id="selectRoom">
                    <option value="">--请选择班级--</option>
                    <foreach name="room" item="vo">
                        <if $student.cid == $vo.id>
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                        <else />
                            <option value="{$vo.id}">{$vo.name}</option>
                        </if>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">学生性别:</label>
            <div class="col-md-6 col-sm-10">
                <if $student.sex==2>
                    <input type="radio" name="sex" value="1"/>男
                    <input type="radio" name="sex" value="2" checked/>女
                <else />
                    <input type="radio" name="sex" value="1" checked/>男
                    <input type="radio" name="sex" value="2" />女
                </if>
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">年龄:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-name" name="age" value="{$student.age}">
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">手机号:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-name" name="mobile" value="{$student.mobile}">
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">身份证号:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-name" name="idcard" value="{$student.idcard}">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('EDIT')}</button>
                <a class="btn btn-default" href="{:url('admin/student/index')}">{:lang('BACK')}</a>
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script src="__STATIC__/layui/layui.all.js"></script>
<script>
    $(function () {
        $('#selectSchool').change('click',function () {
            var schoolId=$('#selectSchool').val();
            $.ajax({
                url:"{:url('student/getRoom')}",
                type:"POST",
                data:{schoolId:schoolId},
                success:function (res) {
                    $('#selectRoom').html(res);
                }
            });
        });
    })
</script>
</body>
</html>